package com.yourbatis.syntax;

import com.yourbatis.interpreter.Environment;

public class PostfixIncrement implements Expression {
    private final String variableName;

    public PostfixIncrement(String variableName) {
        this.variableName = variableName;
    }

    @Override
    public Object eval() {
        // 获取当前值
        int currentValue = (Integer) Environment.get(variableName);
        // 设置新值
        Environment.assign(variableName, currentValue + 1);
        // 返回原始值（后缀运算特性）
        return currentValue;
    }
}
